//
//  ZHomeViewTableViewCell.m
//  OC-weibo
//
//  Created by zero on 17/3/24.
//  Copyright © 2017年 zero. All rights reserved.
//

#import "ZHomeViewTableViewCell.h"
#import "ZStatusOriginalView.h"
#import "ZStatusBottomView.h"
#import "ZStatusRetweetView.h"

@interface ZHomeViewTableViewCell()


//  源博文
@property (nonatomic,weak)ZStatusOriginalView *originalView;
@property (nonatomic,weak)ZStatusRetweetView *retweetView;

@end

@implementation ZHomeViewTableViewCell


#pragma mark
#pragma mark - 重写init的方法

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //  布局
        [self setupUI];
    }
    
    return self;
}

#pragma mark
#pragma mark - 布局
- (void)setupUI{
    
    //  添加源博文
    ZStatusOriginalView *originalView = [[ZStatusOriginalView alloc] init];
    
    self.originalView = originalView;
    
    originalView.backgroundColor = [UIColor whiteColor];
    
    [self.contentView addSubview:originalView];
    
    //  约束
    [originalView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.leading.trailing.offset(0);
        
    }];
    
    //  添加转发的博文
    ZStatusRetweetView *retweetView = [[ZStatusRetweetView alloc] init];
    
    self.retweetView = retweetView;
    retweetView.backgroundColor = [UIColor lightGrayColor];
    
    [self.contentView addSubview:retweetView];
    
    //  添加约束
    [retweetView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(originalView.mas_bottom).offset(8);
        make.leading.trailing.equalTo(self.contentView);
        
    }];
    
    
    //  添加底部
    ZStatusBottomView *bottomView = [[ZStatusBottomView alloc] init];
    
//    bottomView.backgroundColor = [UIColor redColor];
    
    [self.contentView addSubview:bottomView];
    
    //  约束
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(retweetView.mas_bottom).offset(8);
        make.leading.trailing.bottom.equalTo(self.contentView);
    }];
    
}

#pragma mark
#pragma mark - 重写set方法
- (void)setHomeViewModel:(ZHomeModelViewModel *)homeViewModel{
    
    _homeViewModel = homeViewModel;
    
    self.originalView.homeViewModel = homeViewModel;
 
    self.retweetView.homeViewModel = homeViewModel;
}

@end
